﻿<phone:PhoneApplicationPage
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:framework="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" 
                            xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
                            xmlns:local="clr-namespace:CCWP7.CaliburnMicro"
                            xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                            xmlns:behaviors="clr-namespace:CCWP7.CaliburnMicro.Behaviors"
                            behaviors:TiltEffect.IsTiltEnabled="True"
                            x:Class="CCWP7.CaliburnMicro.MainPage"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="PortraitOrLandscape"
                            Orientation="Portrait"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="768"
                            shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="ProjectItemContent">
            <ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding ActiveItem, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <local:ProjectItemControl/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </DataTemplate>
        <Style x:Key="ProjectPivotItemStyle" TargetType="controls:PivotItem">
            <Setter Property="ContentTemplate" Value="{StaticResource ProjectItemContent}"/>
        </Style>
    </phone:PhoneApplicationPage.Resources>
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Opacity="0.595">
            <framework:AppBarButton IconUri="/icons/appbar.add.rest.png" Message="AddServer" Text="add server"/>
            <framework:AppBarButton IconUri="/icons/appbar.refresh.rest.png" Message="RefreshModel" Text="refresh"/>
            <framework:AppBarButton IconUri="/icons/appbar.questionmark.rest.png" Message="About" Text="about"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    <interactivity:Interaction.Triggers>
        <interactivity:EventTrigger>
            <framework:ActionMessage MethodName="RefreshModel"/>
        </interactivity:EventTrigger>
    </interactivity:Interaction.Triggers>
    <Grid x:Name="LayoutRoot" Background="#FF0B486B">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup" ic:ExtendedVisualStateManager.UseFluidLayout="True">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ReadingIndicatorGrid">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Default"/>
                <VisualState x:Name="Reading">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ReadingIndicatorGrid">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <VisualStateManager.CustomVisualStateManager>
            <ic:ExtendedVisualStateManager/>
        </VisualStateManager.CustomVisualStateManager>
        <controls:Pivot x:Name="PivotFilter" 
                        Grid.Row="1" 
                        Title="{StaticResource AppTitle}">
            <controls:PivotItem x:Name="AllProjects" Header="all" Style="{StaticResource ProjectPivotItemStyle}"/>
            <controls:PivotItem x:Name="FailedProjects" Header="failed" Style="{StaticResource ProjectPivotItemStyle}"/>
            <controls:PivotItem x:Name="BuildingProjects" Header="building" Style="{StaticResource ProjectPivotItemStyle}"/>
            <controls:PivotItem Header="servers" DataContext="{Binding Servers}">
                <ListBox x:Name="Items" SelectedItem="{Binding ActiveItem, Mode=TwoWay}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Rectangle Fill="{StaticResource PhoneForegroundBrush}" Height="48" Stroke="Black" Width="32" Margin="4,0">
                                	<Rectangle.OpacityMask>
                                		<ImageBrush Stretch="Fill" ImageSource="icons/server.png"/>
                                	</Rectangle.OpacityMask>
                                </Rectangle>
                                <StackPanel>
                                    <TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextLargeStyle}" />
                                    <TextBlock Text="{Binding LastReportRead}" Style="{StaticResource PhoneTextSubtleStyle}" />
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
        <Grid x:Name="ReadingIndicatorGrid" Height="4" VerticalAlignment="Top" Visibility="Collapsed">
            <ProgressBar IsIndeterminate="True"/>
        </Grid>
    </Grid>


</phone:PhoneApplicationPage>
